﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OpenMHEG.Core.AddIns
{
    internal class AddInManager
    {
        internal void SetupAddIns()
        {
            // Set the add-ins discovery root directory to be the current directory

            string addinRoot = Environment.CurrentDirectory;



            // Rebuild the add-ins cache and pipeline components cache.

            AddInStore.Rebuild(addinRoot);



            // Get registerd add-ins of type SimpleAddInHostView

            Collection<AddInToken> addins = AddInStore.FindAddIns(typeof(SimpleAddInHostView), addinRoot);



            foreach (AddInToken addinToken in addins)
            {

                // Activate the add-in

                SimpleAddInHostView addinInstance =

                   addinToken.Activate<SimpleAddInHostView>(AddInSecurityLevel.Internet);



                // Use the add-in

                Console.WriteLine(String.Format("Add-in {0} Version {1}",

                     addinToken.Name, addinToken.Version));

                Console.WriteLine(addinInstance.SayHello("Guy"));

            }
        }
    }
}
